var provinces = {
	// "热点城市": {
	// "重庆":["重庆"],
	// "三亚":["三亚"],
	// "海口":["海口"],
	// "乌鲁木齐":["乌鲁木齐"]
	// },
	// "A": {
	// "安徽":["安徽"]
	// },
	// "B": {
	// "北京": ["北京"]
	// },
	// "C": {
	// "重庆":["重庆"]
	// },
	// "F": {
	// "福建":["福建"]
	// },
	// "G": {
	// "甘肃":["甘肃"],
	// "广东":["广东"],
	// "广西":["广西"],
	// "贵州":["贵州"]
	// },
	// "H": {
	// "海南":["海南"],
	// "河北":["河北"],
	// "河南":["河南"],
	// "黑龙江":["黑龙江"],
	// "湖北":["湖北"],
	// "湖北":["湖北"],
	// "湖南":["湖南"]
	// },
	// "J": {
	// "吉林":["吉林"],
	// "江苏":["江苏"],
	// "江西":["江西"]
	// },
	// "L": {
	// "辽宁":["辽宁"]
	// },
	// "N": {
	// "内蒙古":["内蒙古"],
	// "宁夏":["宁夏"]
	// },
	// "Q": {
	// "青海":["青海"]
	// },
	// "S": {
	// "山东":["山东"],
	// "山西":["山西"],
	// "陕西":["山西"],
	// "上海":["上海"],
	// "三亚":["三亚"],
	// "四川":["四川"]
	// },
	// "T": {
	// "天津": ["天津"]
	// },
	// "W": {
	// "乌鲁木齐":["乌鲁木齐"]
	// },  
	// "X": {
	// "西藏":["西藏"],
	// "新疆":["新疆"]
	// },
	// "Y": {
	// "云南":["云南"]
	// },
	// "Z": {
	// "浙江":["浙江"]
	// }
};

(function($, win, doc) {
	var CityPicker = function(el, options) {
		console.log(JSON.stringify(options.newObj) + "*********************");
		this.el = $(el);
		this.options = options;
		this.sanzima = options.sanzima;
		this.typesk = options.typesk;
		this.selectsCity = "";
		this.shuZu = "";
		this.ul = "";
		this.li = "";
		//this.provinces = provinces;
		this.provinces = options.newObj;
		this.pro = null;
		this.city = null;
		this.elType = this.el.is('input');
		this.init();
	};
	var p = CityPicker.prototype;
	p.init = function() {
		this.initEvent();
		this.preventPopKeyboard();
	};
	p.preventPopKeyboard = function() {
		if(this.elType) {
			this.el.prop("readonly", false);
		}
	};
	p.initEvent = function() {
		this.el.on("focus", function(e) {
			var pickerBox = $(".picker-box");
			if(pickerBox[0]) {
				pickerBox.show();
			} else {
				this.create();
			}
		}.bind(this));
	};
	//1.页面出来就加载内容和26字母
	p.init = function() {
		this.createCityPickerBox();
		this.createProList();
		this.proClick();
		this.createNavBar();
		this.navEvent();
		this.seach();
	};
	//2.点击才能加载内容和26字母
	// p.create = function () {
	// this.createCityPickerBox();
	// this.createProList();
	// this.proClick();
	// this.createNavBar();
	// this.navEvent();
	// };
	p.createCityPickerBox = function() {
		$("body .scrollbox").html("");
		var proBox = "<div class='picker-box'></div>";
		$("body .scrollbox").append(proBox);
	};
	p.createProList = function() {
		var provinces = this.provinces;
		var proBox;
		var dl = "";

		for(var letterKey in provinces) {
			var val = provinces[letterKey];
			if(provinces.hasOwnProperty(letterKey)) {
				var dt = "<dt id='" + letterKey + "' class='gaopsr'>" + letterKey + "</dt>";
				var dd = "";
				for(var proKey in val) {
					if(val.hasOwnProperty(proKey)) {
						if(val[proKey].toString().indexOf("0") > -1) {
							var kst = val[proKey].toString().substring(0, val[proKey].toString().indexOf("0"));
							dd += "<dd data-letter=" + letterKey + " data-gj=" + 1 + ">" + kst + "</dd>";
						} else if(val[proKey].toString().indexOf("1") > -1) {
							var kst = val[proKey].toString().substring(0, val[proKey].toString().indexOf("1"));
							dd += "<dd data-letter=" + letterKey + " data-gj=" + 2 + ">" + kst + "</dd>";
						} else {
							dd += "<dd data-letter=" + letterKey + " data-gj=" + 0 + ">" + proKey + "</dd>";
						}
					}
				}
				dl += "<dl>" + dt + dd + "</dl>";
			}
		}
		proBox = "<section class='pro-picker'>" + dl + "</section>";
		$(".picker-box").append(proBox);
	};
	p.createCityList = function(pro) {
		var ul, li = "";
		this.li = "";
		shuZu = window.localStorage.getItem("cityshuZu") || "";
		if(!isDefine(shuZu)) {
			shuZu = [pro];
		} else {
			shuZu = shuZu.split(",");
			if(shuZu[0].substring(0, 1) != pro.substring(0, 1)) {
				shuZu = [pro];
				window.localStorage.getItem("cityshuZu", "");
			}
		}
		//console.log(shuZu+"***********"+pro.length);
		if(pro.length > 1) {
			this.iszimuhanzi(pro);
			var ksk = 1;
			for(var k = 1; k < shuZu.length; k++) {
				if(pro.length == 2) {
					var zimul1 = pinyin.getCamelChars(shuZu[k][0]);
					var zimul2 = pinyin.getCamelChars(shuZu[k][1]);
					for(var d = 0; d < zimul1.length; d++) {
						for(var r = 0; r < zimul2.length; r++) {
							if(zimul1[d] + zimul2[r] == pro.toLocaleUpperCase()) {
								if(shuZu[k].toString().indexOf("0") > -1) {
									var kst = shuZu[k].toString().substring(0, shuZu[k].toString().indexOf("0"));
									if(shuZu[k].indexOf(pro) > -1) {
										li += "<li data-gj=" + 1 + ">" + shuZu[k] + "</li>";
										continue;
									}
									li += "<li data-gj=" + 1 + ">" + kst + "</li>";
									break;
								} else {
									if(shuZu[k].indexOf(pro) > -1) {
										li += "<li data-gj=" + 0 + ">" + shuZu[k] + "</li>";
										continue;
									}
									li += "<li data-gj=" + 0 + ">" + shuZu[k] + "</li>";
									break;
								}
							}
						}
					}
				} else if(pro.length == 3) {
					if(shuZu[k].length >= 3) {
						var zimul1 = pinyin.getCamelChars(shuZu[k][0]);
						var zimul2 = pinyin.getCamelChars(shuZu[k][1]);
						var zimul3 = pinyin.getCamelChars(shuZu[k][2]);
						for(var d = 0; d < zimul1.length; d++) {
							for(var r = 0; r < zimul2.length; r++) {
								for(var s = 0; s < zimul3.length; s++) {
									if(zimul1[d] + zimul2[r] + zimul3[s] == pro.toLocaleUpperCase()) {
										if(shuZu[k].toString().indexOf("0") > -1) {
											var kst = shuZu[k].toString().substring(0, shuZu[k].toString().indexOf("0"));
											if(shuZu[k].indexOf(pro) > -1) {
												li += "<li data-gj=" + 1 + ">" + shuZu[k] + "</li>";
												continue;
											}
											li += "<li data-gj=" + 1 + ">" + kst + "</li>";
											break;
										} else {
											if(shuZu[k].indexOf(pro) > -1) {
												li += "<li data-gj=" + 0 + ">" + shuZu[k] + "</li>";
												continue;
											}
											li += "<li data-gj=" + 0 + ">" + shuZu[k] + "</li>";
											break;
										}
									}
								}
							}
						}
					}
				} else if(pro.length == 4) {
					if(shuZu[k].length >= 4) {
						var zimul1 = pinyin.getCamelChars(shuZu[k][0]);
						var zimul2 = pinyin.getCamelChars(shuZu[k][1]);
						var zimul3 = pinyin.getCamelChars(shuZu[k][2]);
						var zimul4 = pinyin.getCamelChars(shuZu[k][3]);
						for(var d = 0; d < zimul1.length; d++) {
							for(var r = 0; r < zimul2.length; r++) {
								for(var s = 0; s < zimul3.length; s++) {
									for(var f = 0; f < zimul4.length; f++) {
										if(zimul1[d] + zimul2[r] + zimul3[s] + zimul4[f] == pro.toLocaleUpperCase()) {
											if(shuZu[k].toString().indexOf("0") > -1) {
												var kst = shuZu[k].toString().substring(0, shuZu[k].toString().indexOf("0"));
												if(shuZu[k].indexOf(pro) > -1) {
													li += "<li data-gj=" + 1 + ">" + shuZu[k] + "</li>";
													continue;
												}
												li += "<li data-gj=" + 1 + ">" + kst + "</li>";
												break;
											} else {
												if(shuZu[k].indexOf(pro) > -1) {
													li += "<li data-gj=" + 0 + ">" + shuZu[k] + "</li>";
													continue;
												}
												li += "<li data-gj=" + 0 + ">" + shuZu[k] + "</li>";
												break;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		} else {
			this.iszimuhanzi(pro);
		}
		li += this.li;
		window.localStorage.setItem("cityshuZu", shuZu);
		ul = "<ul class='city-picker'>" + li + "</ul>";
		$(".picker-box").find(".city-picker").remove().end().append(ul);
		if($(".picker-box").find(".city-picker").find("li").html() != "没有该出发城市") {
			this.cityClick();
		}
	};
	p.iszimuhanzi = function(pro) { //第一次是字母还是数字模糊查询
		var li = "";
		var ksk = 1;
		for(var p in this.provinces) {
			if(p != "热点城市") {
				//shuZu = "";
				//appcan.locStorage.val("cityshuZu","");
				for(var k in this.provinces[p]) {
					var cities = this.provinces[p][k];
					cities.forEach(function(city, i) {
						if(city.toString().indexOf("0") > -1) {
							var kst = city.toString().substring(0, city.toString().indexOf("0"));
							if(city.indexOf(pro) > -1) {
								li += "<li data-gj=" + 1 + ">" + kst + "</li>";
								shuZu[ksk] = kst + "0";
								ksk++;
								return true;
							}
							//alert(city+"=="+pro);
							for(var ks = 0; ks < kst.length; ks++) {
								var zimul = pinyin.getCamelChars(kst[ks]);
								for(var kks = 0; kks < zimul.length; kks++) {
									//alert(pinyin.getCamelChars(city)[kks]+"***"+city);                      
									if(zimul[kks].indexOf(pro.toLocaleUpperCase()) > -1) {
										li += "<li data-gj=" + 1 + ">" + kst + "</li>";
										shuZu[ksk] = kst + "0";
										ksk++;
										return true;
									}
								}
							}
						} else if(city.toString().indexOf("1") > -1) {
							var kst = city.toString().substring(0, city.toString().indexOf("1"));
							if(city.indexOf(pro) > -1) {
								li += "<li data-gj=" + 2 + ">" + kst + "</li>";
								shuZu[ksk] = kst + "1";
								ksk++;
								return true;
							}
							//alert(city+"=="+pro);
							for(var ks = 0; ks < kst.length; ks++) {
								var zimul = pinyin.getCamelChars(kst[ks]);
								for(var kks = 0; kks < zimul.length; kks++) {
									//alert(pinyin.getCamelChars(city)[kks]+"***"+city);                      
									if(zimul[kks].indexOf(pro.toLocaleUpperCase()) > -1) {
										li += "<li data-gj=" + 2 + ">" + kst + "</li>";
										shuZu[ksk] = kst + "1";
										ksk++;
										return true;
									}
								}
							}
						} else {
							if(city.indexOf(pro) > -1) {
								li += "<li data-gj=" + 0 + ">" + city + "</li>";
								shuZu[ksk] = city;
								ksk++;
								return true;
							}
							//alert(city+"=="+pro);
							for(var ks = 0; ks < city.length; ks++) {
								var zimul = pinyin.getCamelChars(city[ks]);
								for(var kks = 0; kks < zimul.length; kks++) {
									//alert(pinyin.getCamelChars(city)[kks]+"***");                      
									if(zimul[kks].indexOf(pro.toLocaleUpperCase()) > -1) {
										li += "<li data-gj=" + 0 + ">" + city + "</li>";
										//alert(city+"="+ksk);
										shuZu[ksk] = city;
										ksk++;
										return true;
									}
								}
							}
						}
					});
				}
			}
		}
		this.li = li;
	};
	var citks;
	p.cityClick = function() {
		var that = this;
		$(".city-picker").on("click", function(e) {
			var target = e.target;
			if($(target).is("li")) {
				that.city = $(target).html();
				var type = $(target).data("gj");
				if(that.elType) {
					//that.el.val(that.city);
					var indexType = that.city;
					var sanzima = "";

					if(type == 0) {
						for(var ps in that.sanzima.domMap) {
							if(that.sanzima.domMap[ps][0] == indexType) {
								sanzima = ps;
							}
						}
					} else if(type == 1) {
						for(var ps in that.sanzima.intMap) {
							if(that.sanzima.intMap[ps][0] == indexType + "0") {
								sanzima = ps;
							}
						}
					} else if(type == 2) {
						for(var ps in that.sanzima.passportCountry) {
							if(that.sanzima.passportCountry[ps][0] == indexType + "1") {
								sanzima = ps;
							}
						}
					}
					var cityparam = {
						'city': indexType,
						'sanzima': sanzima,
						'type': type,
						'selectsCity': that.selectsCity
					}
					var okDynamic = window.localStorage.getItem("okDynamic");
					if(okDynamic == "1") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".startCity").html(cityparam.city);
						$(".startCity").attr("data-szm", cityparam.sanzima);
						$(".startCity").attr("startcity", cityparam.sanzima);
						$(".startCity").attr("data-type", cityparam.type);
						var citychoose = JSON.parse(window.localStorage.getItem("choosecity"));
						citychoose.startctiy = cityparam.city;
						citychoose.startsanzima = cityparam.sanzima;
						citychoose.starttype = cityparam.type;
						window.localStorage.setItem("choosecity", JSON.stringify(citychoose));
						chooseXJP();
						window.localStorage.setItem("okDynamic", "0");
					}
					if(okDynamic == "2") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".endCity").attr("data-szm", cityparam.sanzima);
						$(".endCity").html(cityparam.city);
						$(".endCity").attr("endcity", cityparam.sanzima);
						$(".endCity").attr("data-type", cityparam.type);
						var citychoose = JSON.parse(window.localStorage.getItem("choosecity"));
						citychoose.endctiy = cityparam.city;
						citychoose.endsanzima = cityparam.sanzima;
						citychoose.endtype = cityparam.type;
						window.localStorage.setItem("choosecity", JSON.stringify(citychoose));
						chooseXJP();
						window.localStorage.setItem("okDynamic", "0");
					}
					//签发国
					if(okDynamic == "3") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".signcountry").html(cityparam.city);
						$(".signcountry").attr("data-val", cityparam.sanzima);
						window.localStorage.setItem("okDynamic", "0");
					}
					//国籍
					if(okDynamic == "4") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".nationality").html(cityparam.city);
						$(".nationality").attr("data-val", cityparam.sanzima);
						window.localStorage.setItem("okDynamic", "0");
					}
				} else {
					//that.el.html(that.city);
					var indexType = that.city;
					var sanzima = "";
					if(type == 0) {
						for(var ps in that.sanzima.domMap) {
							if(that.sanzima.domMap[ps][0] == indexType) {
								sanzima = ps;
							}
						}
					} else if(type == 1) {
						for(var ps in that.sanzima.intMap) {
							if(that.sanzima.intMap[ps][0] == indexType) {
								sanzima = ps;
							}
						}
					} else if(type == 2) {
						for(var ps in that.sanzima.passportCountry) {
							if(that.sanzima.passportCountry[ps][0] == indexType + "1") {
								sanzima = ps;
							}
						}
					}
					var cityparam = {
						'city': indexType,
						'sanzima': sanzima,
						'type': type,
						'selectsCity': that.selectsCity
					}

					console.log(cityparam)
					var okDynamic = window.localStorage.getItem("okDynamic");
					if(okDynamic == "1") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".startCity").html(cityparam.city);
						$(".startCity").attr("data-szm", cityparam.sanzima);
						$(".startCity").attr("startcity", cityparam.sanzima);
						$(".startCity").attr("data-type", cityparam.type);
						var citychoose = JSON.parse(window.localStorage.getItem("choosecity"));
						citychoose.startctiy = cityparam.city;
						citychoose.startsanzima = cityparam.sanzima;
						citychoose.starttype = cityparam.type;
						window.localStorage.setItem("choosecity", JSON.stringify(citychoose));
						chooseXJP();
						window.localStorage.setItem("okDynamic", "0");
					}
					if(okDynamic == "2") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".endCity").html(cityparam.city);
						$(".endCity").attr("data-szm", cityparam.sanzima);
						$(".endCity").attr("endcity", cityparam.sanzima);
						$(".endCity").attr("data-type", cityparam.type);
						var citychoose = JSON.parse(window.localStorage.getItem("choosecity"));
						citychoose.endctiy = cityparam.city;
						citychoose.endsanzima = cityparam.sanzima;
						citychoose.endtype = cityparam.type;
						window.localStorage.setItem("choosecity", JSON.stringify(citychoose));
						chooseXJP();
						window.localStorage.setItem("okDynamic", "0");
					}
					//签发国
					if(okDynamic == "3") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".signcountry").html(cityparam.city);
						$(".signcountry").attr("data-val", cityparam.sanzima);
						window.localStorage.setItem("okDynamic", "0");
					}
					//国籍
					if(okDynamic == "4") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".nationality").html(cityparam.city);
						$(".nationality").attr("data-val", cityparam.sanzima);
						window.localStorage.setItem("okDynamic", "0");
					}
					//appcan.window.publish("city",cityparam);
					//uexWindow.evaluateScript("", 0, "appcan.window.close(-1);");
				}
				//      $(".picker-box").hide();
				//      $(".pro-picker").show();
				//      $(this).hide();
			}
		});
	};
	p.proClick = function() {
		var that = this;
		$(".pro-picker").on("click", function(e) {

			var target = e.target;
			if($(target).is("dd")) {
				that.pro = $(target).html();
				var type = $(target).data("gj");
				var letter = $(target).data("letter");
				//that.createCityList(letter, that.pro);
				if(that.elType) {
					//that.el.val(that.pro);
					var indexType = that.pro;
					var sanzima = "";
					//alert(JSON.stringify(that.sanzima));
					if(type == 0) {
						for(var ps in that.sanzima.domMap) {
							if(that.sanzima.domMap[ps][0] == indexType) {
								sanzima = ps;
							}
						}
					} else if(type == 1) {
						for(var ps in that.sanzima.intMap) {
							if(that.sanzima.intMap[ps][0] == indexType + "0") {
								sanzima = ps;
							}
						}
					} else if(type == 2) {
						for(var ps in that.sanzima.passportCountry) {
							if(that.sanzima.passportCountry[ps][0] == indexType + "1") {
								sanzima = ps;
							}
						}
					}
					var cityparam = {
						'city': indexType,
						'sanzima': sanzima,
						'type': type,
						'selectsCity': that.selectsCity
					}
					var okDynamic = window.localStorage.getItem("okDynamic");
					if(okDynamic == "1") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".startCity").html(cityparam.city);
						$(".startCity").attr("data-szm", cityparam.sanzima);
						$(".startCity").attr("startcity", cityparam.sanzima);
						$(".startCity").attr("data-type", cityparam.type);
						var citychoose = JSON.parse(window.localStorage.getItem("choosecity"));
						citychoose.startctiy = cityparam.city;
						citychoose.startsanzima = cityparam.sanzima;
						citychoose.starttype = cityparam.type;
						window.localStorage.setItem("choosecity", JSON.stringify(citychoose));
						chooseXJP();
						window.localStorage.setItem("okDynamic", "0");
					}
					if(okDynamic == "2") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".endCity").html(cityparam.city);
						$(".endCity").attr("data-szm", cityparam.sanzima);
						$(".endCity").attr("endcity", cityparam.sanzima);
						$(".endCity").attr("data-type", cityparam.type);
						var citychoose = JSON.parse(window.localStorage.getItem("choosecity"));
						citychoose.endctiy = cityparam.city;
						citychoose.endsanzima = cityparam.sanzima;
						citychoose.endtype = cityparam.type;
						window.localStorage.setItem("choosecity", JSON.stringify(citychoose));
						chooseXJP();
						window.localStorage.setItem("okDynamic", "0");
					}
					//签发国
					if(okDynamic == "3") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".signcountry").html(cityparam.city);
						$(".signcountry").attr("data-val", cityparam.sanzima);
						window.localStorage.setItem("okDynamic", "0");
					}
					//国籍
					if(okDynamic == "4") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".nationality").html(cityparam.city);
						$(".nationality").attr("data-val", cityparam.sanzima);
						window.localStorage.setItem("okDynamic", "0");
					}
					//appcan.window.publish("city",cityparam);
					//uexWindow.evaluateScript("", 0, "appcan.window.close(-1);");
				} else {
					//that.el.html(that.pro);
					var indexType = that.pro;
					var sanzima = "";
					//alert(that.sanzima);

					if(type == 0) {
						for(var ps in that.sanzima.domMap) {
							if(that.sanzima.domMap[ps][0] == indexType) {
								sanzima = ps;
							}
						}
					} else if(type == 1) {
						for(var ps in that.sanzima.intMap) {
							if(that.sanzima.intMap[ps][0] == indexType) {
								sanzima = ps;
							}
						}
					} else if(type == 2) {
						for(var ps in that.sanzima.passportCountry) {
							if(that.sanzima.passportCountry[ps][0] == indexType + "1") {
								sanzima = ps;
							}
						}
					}
					var cityparam = {
						'city': indexType,
						'sanzima': sanzima,
						'type': type,
						'selectsCity': that.selectsCity
					}
					var okDynamic = window.localStorage.getItem("okDynamic");
					if(okDynamic == "1") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".startCity").html(cityparam.city);
						$(".startCity").attr("data-szm", cityparam.sanzima);
						$(".startCity").attr("startcity", cityparam.sanzima);
						$(".startCity").attr("data-type", cityparam.type);
						var citychoose = JSON.parse(window.localStorage.getItem("choosecity"));
						citychoose.startctiy = cityparam.city;
						citychoose.startsanzima = cityparam.sanzima;
						citychoose.starttype = cityparam.type;
						window.localStorage.setItem("choosecity", JSON.stringify(citychoose));
						chooseXJP();
						window.localStorage.setItem("okDynamic", "0");
					}
					if(okDynamic == "2") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".endCity").html(cityparam.city);
						$(".endCity").attr("data-szm", cityparam.sanzima);
						$(".endCity").attr("endcity", cityparam.sanzima);
						$(".endCity").attr("data-type", cityparam.type);
						var citychoose = JSON.parse(window.localStorage.getItem("choosecity"));
						citychoose.endctiy = cityparam.city;
						citychoose.endsanzima = cityparam.sanzima;
						citychoose.endtype = cityparam.type;
						window.localStorage.setItem("choosecity", JSON.stringify(citychoose));
						chooseXJP();
						window.localStorage.setItem("okDynamic", "0");
					}
					//签发国
					if(okDynamic == "3") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".signcountry").html(cityparam.city);
						$(".signcountry").attr("data-val", cityparam.sanzima);
						window.localStorage.setItem("okDynamic", "0");
					}
					//国籍
					if(okDynamic == "4") {
						$(".ders").addClass("uhide");
						$(".scrollContent").removeClass("uhide");
						$(".nationality").html(cityparam.city);
						$(".nationality").attr("data-val", cityparam.sanzima);
						window.localStorage.setItem("okDynamic", "0");
					}
					// appcan.window.publish("city",cityparam);
					//uexWindow.evaluateScript("", 0, "appcan.window.close(-1);");
				}
				//      $(".picker-box").hide();
				//      $(".pro-picker").show();
				//      $(this).hide();
			}
		});
	};
	p.seach = function() {
		var that = this;
		$('.city').bind('input propertychange', function() {
			var kk = $(".city").val();
			//$(".city").val("");
			//var letter = "A";
			if(kk != "") {
				$(".city-picker").remove();
				$(".pro-picker").hide();
				//setTimeout(function(){
				that.createCityList(kk);
				//},500);
			} else {
				$(".city-picker").remove();
				$(".pro-picker").show();
			}

		});
	};
	p.createNavBar = function() {
		var str = "";
		for(var p in this.provinces) {
			if(p != "热点城市") {
				str += p;
			}
		}
		//var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		var arr = str.split("");
		var a = "";
		arr.forEach(function(item, i) {
			if(i == 0) {
				a += '<a href="#' + item + '" class="fchild">' + item + '</a>';
			} else if(i == arr.length - 1) {
				a += '<a href="#' + item + '" class="lchild">' + item + '</a>';
			} else {
				a += '<a href="#' + item + '">' + item + '</a>';
			}
		});
		var div = '<div class="navbar">' + a + '</div>';
		//$(".picker-box").append(div);
		$(".pro-picker").append(div);
		if(this.typesk == 2) {
			$(".navbar").css("top", "25.5em");
		} else if(this.typesk == 1) {
			$(".navbar").css("top", "25.5em");
		}
	};
	p.navEvent = function() {
		var that = this;
		var navBar = $(".navbar");
		var width = navBar.find("a").width();
		var height = navBar.find("a").height();
		navBar.on("touchstart", function(e) {
			$(this).addClass("active");
			var flag = $(e.target).html();
			var navheight=$('header').height();
			$('html,body').scrollTop($("#"+flag).offset().top-navheight);
			that.createLetterPrompt($(e.target).html());
			e.stopPropagation();
			e.preventDefault();
		});
		navBar.on("touchmove", function(e) {
			e.stopPropagation();
			e.preventDefault();
			var touch = e.originalEvent.touches[0];
			var pos = { "x": touch.pageX, "y": touch.pageY };
			var x = pos.x,
				y = pos.y;
			$(this).find("a").each(function(i, item) {
				var offset = $(item).offset();
				//console.log(offset);
				var left = offset.left,
					top = offset.top;
				//alert(x+"=="+left+"=="+width+"=="+y+"==="+top+"=="+height+"=="+(top + height));
				if(x > left && x < (left + width) && y > top && y < (top + height)) {
					var flag = $(item).html()
					//history.pushState && history.replaceState({ title: flag }, flag, '#' + flag);
					//location.href = item.href;//锚跳到相应位置
					var navheight=$('header').height();
					$('html,body').scrollTop($("#"+flag).offset().top-navheight);
					that.changeLetter($(item).html());
				}
			});
		});
		navBar.on("touchend", function() {
			$(this).removeClass("active");
			$(".prompt").hide();
		})
	};
	p.createLetterPrompt = function(letter) {
		var prompt = $(".prompt");
	
		if(prompt[0]) {
			prompt.html(letter);
			prompt.show();
			
		} else {
			var span = "<span class='prompt'>" + letter + "</span>";
			$(".picker-box").append(span);
			
		}
		
	};
	p.changeLetter = function(letter) {
		var prompt = $(".prompt");
		prompt.html(letter);
	};
	$.fn.CityPicker = function(options) {
		return new CityPicker(this, options);
	}
}(window.jQuery, window, document));

//选择新加坡时
function chooseXJP() {
		if($(".startCity").attr("data-type") == "1" || $(".endCity").attr("data-type") == "1" ){
			$(".typeRows-ye").addClass("uhide");
			var strcount = window.localStorage.getItem("strcount");
			if(isDefine(strcount)) {
				strcounts = JSON.parse(strcount);
				adt = strcounts.adt;
				cnn = strcounts.cnn;
				inf = 0;
				if(cnn == 0){
						$(".counts").html(adt+"成人");
				}else{
						$(".counts").html(adt+"成人,"+cnn+"儿童");
				}
			}else{
				adt = 1;
				cnn = 0;
				inf = 0;
				$(".counts").html("1成人");
			}
		}else{
			$(".typeRows-ye").removeClass("uhide");
			//alert(strcount);
			var strcount = window.localStorage.getItem("strcount");
			if(isDefine(strcount)) {
				strcounts = JSON.parse(strcount);
				adt = strcounts.adt;
				cnn = strcounts.cnn;
				inf = strcounts.inf;
				$(".counts").html(strcounts.str);
			}else{
				adt = 1;
				cnn = 0;
				inf = 0;
				$(".counts").html("1成人");
			}
		}
	}
export default {};